<script>
import {defineComponent} from 'vue'

export default defineComponent({
  name: "Item",
  methods: {
    change(id, e) {
      this.changeDone(id, e.target.checked)
    },
    removeById(id){
     this.removeTodoObj(id)
    }
  },
  data(){
    return{

    }
  },
  props: {
    todo: {
      type: Object,
      required: true
    },
    changeDone: {
      type: Function,
      required: true
    },
    removeTodoObj:{
      type: Function,
      required: true
    }
  }
})
</script>

<template>
  <li class="item">
    <div>
      <input type="checkbox" @change="change(todo.id,$event)" :checked="todo.done"><span>{{ todo.title }}</span>
    </div>
    <button @click="removeById(todo.id)">删除</button>
  </li>
</template>

<style scoped lang="less">
.item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 10px;
  border-bottom: 2px solid #DCDCDC;
  cursor: pointer;

  button {
    width: 50px;
    height: 25px;
    background-color: cornflowerblue;
    color: #fff;
    border: 0;
    cursor: pointer;
    border-radius: 10px;
  }

  div {
    span {
      font-size: 18px;
      margin-left: 5px;
    }
  }
}
</style>
